package com.sophialex.health.record.common.util;

import org.eclipse.swt.graphics.Color;

import com.sophialex.health.system.frame.resource.RcpResourceManager;
import com.sophialex.health.system.frame.widgets.dbTable.DbTable;
import com.sophialex.health.system.frame.widgets.dbTable.TableLabelProvider;

/**
 * DbTable隔行换色样式提供器
 * @author Alex
 */
public class BaseLabelProvider extends TableLabelProvider{
	private final Color rowColor = RcpResourceManager.getColor(240,243,248);
	private Object current = null;
	private int currentColor = 0;
	private DbTable dbTable;
	public BaseLabelProvider(DbTable<?> dbTable) {
		super(dbTable);
		this.dbTable=dbTable;
	}
	@Override
	public Color getBackground(Object element, int columnIndex) {
		// TODO Auto-generated method stub
		if(element.equals(dbTable.getElementAt(0))){
			currentColor=0;
			return null;
		};
		if (current != element) {
			currentColor = 1 - currentColor;
			current = element;
		}
		if (currentColor == 0)
			return null;
		else
			return rowColor;
	}
}
